<template>
  <simple-table
    :url-list="urlList"
    :current-use-btn-list="currentUseBtnList"
    :filed-property-list="filedPropertyList"
    submit-form-title="外部员工信息"
    table-name="externalStaff"
  >
  </simple-table>
</template>

<script lang="ts" setup>
import { TableUrl } from "@/models/TableSetting";
import SimpleTable from "@/components/table/simple/SimpleTable.vue";
import { BtnNameEnum } from "@/components/table/simple/BtnNameEnum";
import { RuleEnum } from "@/components/form/basic/FormEnum";
import { ValidateRules } from "@/components/table/validateRules/ValidateRules";

const urlList = {
  refreshUrl: "/basic-request/ExternalStaff/search",
  modifyingSingleUrl: "/basic-request/ExternalStaff",
  modifyingBatchUrl: "/basic-request/ExternalStaff/batch",
  deleteUrl: "/basic-request/ExternalStaff/batch-delete",
} as TableUrl;

// 当前页面使用的功能按钮
const currentUseBtnList: BtnNameEnum[] = [
  BtnNameEnum.ADD,
  BtnNameEnum.REFRESH,
  BtnNameEnum.DELETE,
  BtnNameEnum.BATCH_IMPORT,
  BtnNameEnum.BATCH_IMPORT_TEMPLATE,
];
const { PhoneValidate, IDCardValidate } = ValidateRules();
const filedPropertyList = [
  {
    filedName: "id",
    label: "ID",
    span: 8,
    width: 100,
    minWidth: 100,
    showInTable: false,
    showInForm: false,
    formType: "el-form-text",
  },
  {
    filedName: "no",
    label: "工号",
    width: 220,
    minWidth: 120,
    showInTable: true,
    showInForm: true,
    formType: "el-form-text",
    rules: [
      {
        ruleName: RuleEnum.REQUIRED,
        ruleValue: true,
        message: "工号不能为空",
      },
    ],
  },
  {
    filedName: "name",
    label: "姓名",
    width: 220,
    minWidth: 120,
    showInTable: true,
    showInForm: true,
    formType: "el-form-text",
    rules: [
      {
        ruleName: RuleEnum.REQUIRED,
        ruleValue: true,
        message: "姓名不能为空",
      },
    ],
  },
  {
    filedName: "phone",
    label: "手机号",
    width: 220,
    minWidth: 120,
    showInTable: true,
    showInForm: true,
    formType: "el-form-text",
    rules: [
      {
        ruleName: RuleEnum.REQUIRED,
        ruleValue: true,
        message: "手机号不能为空",
      },
      {
        ruleName: RuleEnum.VALIDATOR,
        ruleValue: PhoneValidate,
        message: "手机号格式不正确",
      },
    ],
  },
  {
    filedName: "sex",
    label: "性别",
    width: 220,
    minWidth: 120,
    showInTable: true,
    showInForm: true,
    formType: "el-select-radio",
    formatter: {
      boolean: [
        { label: "男", value: true },
        { label: "女", value: false },
      ],
    },
    meta: {
      optionList: [
        { label: "男", value: true },
        { label: "女", value: false },
      ],
    },
    rules: [
      {
        ruleName: RuleEnum.REQUIRED,
        ruleValue: true,
        message: "性别不能为空",
      },
    ],
  },
  {
    filedName: "contractTeamName",
    label: "所属承包队队名",
    width: 220,
    minWidth: 120,
    showInTable: true,
    showInForm: true,
    formType: "el-form-text",
    rules: [
      {
        ruleName: RuleEnum.REQUIRED,
        ruleValue: true,
        message: "所属承包队队名不能为空",
      },
    ],
  },
  {
    filedName: "identify",
    label: "身份证号",
    width: 220,
    minWidth: 120,
    showInTable: true,
    showInForm: true,
    formType: "el-form-text",
    rules: [
      {
        ruleName: RuleEnum.REQUIRED,
        ruleValue: true,
        message: "身份证号不能为空",
      },
      {
        ruleName: RuleEnum.VALIDATOR,
        ruleValue: IDCardValidate,
        message: "身份证号格式不正确",
      },
    ],
  },
  {
    filedName: "createUser",
    label: "创建人",
    span: 8,
    minWidth: 220,
    showInTable: true,
    showInForm: false,
    formType: "el-form-text",
  },
  {
    filedName: "createGmt",
    label: "创建时间",
    span: 8,
    minWidth: 230,
    showInTable: true,
    showInForm: false,
    formType: "el-form-picker-date",
  },
  {
    filedName: "modifiedUser",
    label: "修改人",
    span: 8,
    minWidth: 220,
    showInTable: true,
    showInForm: false,
    formType: "el-form-text",
  },
  {
    filedName: "modifiedGmt",
    label: "修改时间",
    span: 8,
    minWidth: 230,
    showInTable: true,
    showInForm: false,
    formType: "el-form-picker-date",
  },
];
</script>

<style scoped></style>
